'''
Created on 2009-10-22

@author: summit
'''

from jolly.datamanagement.vtkPythonDataManager import *
from jolly.datamanagement.vtkPythonMetaImageData import *
from jolly.tvisual.tvisualbase import *

from enthought.traits import api as traits
from enthought.traits.ui import api as traitsui


class PythonDataManager(tvisualbase):
    '''
    classdocs
    '''
    
    def __init__(self, obj=None, update=True, **traits):
        '''Object initialization.
        
        Parameters
        ----------
        - obj: `vtkPythonDataManage` (default: None)
          An optional VTK object.  If passed the passed object is
          wrapped.  This defaults to `None` where a new VTK instance
          of class, `klass` is created.
        - update: `bool` (default: True)

          If True (default), the traits of the class are automatically
          updated based on the state of the wrapped VTK object.  If
          False, no updation is performed.  This is particularly
          useful when the object is being unpickled.

        - traits: `dict`

          A dictionary having the names of the traits as its keys.
          This allows a user to set the traits of the object while
          creating the object.
        '''
        tvisualbase.__init__(self, vtkPythonDataManager, obj, update, **traits)
  
    number_metadataset = traits.Int()
    
    file_lists = traits.List(traits.Str)
    
    def _file_lists_updated(self):
        print "hello"
    
    _updateable_traits_ = (('number_metadataset', 'GetNumberOfMetaDataSet'),
                           ('file_lists', 'GetAllTagInManager'))
    traits_view = traitsui.View((['number_metadataset'],[traitsui.Item(name='file_lists', editor=traitsui.CheckListEditor(values=["opt1","opt2","opt3"]),style='custom')]),
    title='Edit PythonDataManager properties', scrollable=True, resizable=True,
    buttons=['OK', 'Cancel'])

if __name__=="__main__":
#    x = vtkPythonDataManager()
#    y = vtkPythonMetaImageData()
#    y.Read('c:/head/brain_001.dcm')
#    y.setTag('c:/head/brain_001.dcm')
#    y1 = vtkPythonMetaImageData()
#    y1.Read('c:/head/brain_002.dcm')
#    y1.setTag('c:/head/brain_002.dcm')
#    x.AddMetaDataSet(y)
#    x.AddMetaDataSet(y1)
#    PythonDataManager(x).configure_traits()
    import numpy
    sum_money = numpy.sum([111.2, 42.7, 106, 49.2])
    for i in [111.2, 42.7, 106, 49.2]:
        print "i", i-sum_money/4